﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace Framework.Zhaogang.Cache.Core
{
    /// <summary>
    /// 缓存管理接口
    /// </summary>
    public interface ICacheManager
    {
        /// <summary>
        /// 缓存区域名称
        /// </summary>
        string RegionName { get; }

        /// <summary>
        /// 覆盖
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="isAbsoluteExpire"></param>
        /// <param name="expireMinutes"></param>
        bool Set(string key, object value, bool isAbsoluteExpire = true, int expireMinutes = 0);

        /// <summary>
        /// 移除
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        object Remove(string key);

        /// <summary>
        /// 获取
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        T Get<T>(string key);

        /// <summary>
        /// 是否存在键
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool HasKey(string key);

        /// <summary>
        /// 根据条件模糊查询（慎用）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="expression"></param>
        /// <param name="keyParam"></param>
        /// <returns></returns>
        IEnumerable<T> Where<T>(Func<T, bool> expression, string keyParam = "");
    }
}
